package edu.ncsu.csc.itrust.beans;

/**
 * LabTechProcedureBean stores the information relating to the view of
 * available lab techs to be used in the creation and modification of
 * Lab Procedures. No functionality outside of getters and setters is 
 * present in the bean.
 * @author elmulle2
 *
 */
public class LabTechProcedureBean implements java.lang.Comparable{
	
	/**
	 * private attributes
	 */
	//for name, specialty
	private String firstName, lastName, specialty;
	
	//for total number of lab procedures assigned to the tech
	private int totalProcedures;
	
	//for total jobs by priority
	private int totalP1, totalP2,totalP3;
	
	//for identification
	private long ltid;
	
	/**
	 * Paramaterized Constructor
	 * @param first The first name of the tech
	 * @param last The last name of the tech
	 * @param ltid The MID of the lt in question
	 * @param specialty The specialty of the tech
	 * @param totalP1 The amount of the techs priority 1 procedures
	 * @param totalP2 The amount of the techs priority 2 procedures
	 * @param totalP3 The amount of the techs priority 3 procedures
	 */
	public LabTechProcedureBean(String first, String last,long ltid, String specialty, int totalP1, int totalP2, int totalP3){
		this.firstName = first;
		this.lastName = last;
		this.ltid = ltid;
		this.specialty = specialty;
		this.totalP1 = totalP1;
		this.totalP2 = totalP2;
		this.totalP3 = totalP3;
		this.totalProcedures = totalP1 + totalP2 + totalP3;
	}
	
	/**
	 * all getters and setters for the above attributes
	 */
	
	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	
	public String getName(){ return firstName+" "+lastName; }
	
	public String getSpecialty() {
		return specialty;
	}
	
	public void setSpecialty(String specialty){
		this.specialty = specialty;
	}

	public int getTotalProcedures() {
		return totalProcedures;
	}

	public void setTotalProcedures(int totalProcedures) {
		this.totalProcedures = totalProcedures;
	}

	public int getTotalP1() {
		return totalP1;
	}

	public void setTotalP1(int totalP1) {
		this.totalP1 = totalP1;
	}

	public int getTotalP2() {
		return totalP2;
	}

	public void setTotalP2(int totalP2) {
		this.totalP2 = totalP2;
	}

	public int getTotalP3() {
		return totalP3;
	}

	public void setTotalP3(int totalP3) {
		this.totalP3 = totalP3;
	}
	
	public long getLtId(){
		return ltid;
	}
	
	public void setLtId(long id){
		this.ltid = id;
	}

	/**
	 * Override of the compareTo method for use with sorting beans 
	 * for the editOfficeVisitAction class @link
	 * @param o The object compare.
	 * @return The difference of priorites starting with total or 1 if all equal
	 * 			null return if object is not of type LabTechProcedureBean.
	 */
	public int compareTo(Object o){
		if( !(o instanceof LabTechProcedureBean) ){
			return 0;
		}else{
			LabTechProcedureBean bean = (LabTechProcedureBean) o;
			int difference = this.totalProcedures - bean.getTotalProcedures();
			int p1difference = this.totalP1 - bean.getTotalP1();
			int p2difference = this.totalP2 - bean.getTotalP1();
			int p3difference =  this.totalP3 - bean.getTotalP1();
			if( difference == 0 && p1difference == 0 && p2difference == 0 && p3difference == 0 &&
					this.ltid != bean.getLtId() ){
				return 1;
			}
			if(difference != 0){
				return difference;
			}else if(p1difference != 0 ){
				return p1difference;
			}else if(p2difference != 0){
				return p2difference;
			}else if(p3difference != 0){
				return p3difference;
			}else{
				return 1;
			}				
		}
	}
}
